Skip to content

Upgrade to mdbook 0.5.1 (breaking)#136

Merged
blandger merged 4 commits intoMichael-F-Bryan:masterfrom
michalfita:amend-to-mdbook-v0.5.1
Dec 9, 2025
Merged

Upgrade to mdbook 0.5.1 (breaking)#136
blandger merged 4 commits intoMichael-F-Bryan:masterfrom
michalfita:amend-to-mdbook-v0.5.1

Conversation

@michalfita
Copy link
Contributor

This PR:

  • Updates dependencies
  • Addresses breaking incompatibility with mdbook v0.5.1
    • Library crates are now separate
    • Some minor API changes

This would render mdbook-epub not backward compatible with mdbook v0.4.x

Fixes: #134

@michalfita
Copy link
Contributor Author

Checking tests on CI. They didn't fail me.

@blandger
Copy link
Collaborator

Checking tests on CI. They didn't fail me.

I will merge my prepared PR first with important fixes then you'd be better to merge changes to your PR pls.
Then we'll see CI/CD results.

@blandger
Copy link
Collaborator

blandger commented Nov 30, 2025

Pls, do not level up crates in dependencies higher then they are present in oficial mdbook project.
Pls align all crates versions with mdbook (0.5) then they are present in mdbook-epub. Rise only those crates that are missing in 'mdbook'.
Otherwise we can get a problem (long story to explaine a point)

There are failing tests that I don't understand
…0.5.1

Adjust everything to compile and use matching versions of dependencies.
@michalfita
Copy link
Contributor Author

Pls, do not level up crates in dependencies higher then they are present in oficial mdbook project.

I moved back a little those which had bigger version than mdbook v0.5.1. But switched log to tracing as that's what official mdbook is using right now.

There are still failing tests I don't know how to fix as they complain about error in duplicated paths, what may mean new version of mdbook generates them differently.

@michalfita
Copy link
Contributor Author

---- test_long_book_lookup_chapter_2_image_link_in_readme stdout ----

thread 'test_long_book_lookup_chapter_2_image_link_in_readme' (11689) panicked at tests/long_book_example.rs:66:54:
called `Result::unwrap()` on an `Err` value: EpubBuilder(ZipErrorWithMessage { msg: "could not create file 'OEBPS/01_getting_started/02_article.html' in epub", cause: InvalidArchive("Duplicate filename: OEBPS/01_getting_started/02_article.html") })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Same failure I'm getting. But the path in the error seem to be one inside EPUB, not path on the disk. I have no idea why it's duplicated while wasn't previously.

@michalfita
Copy link
Contributor Author

During generation the failure is propagated from ZIP writing as an attempt is made to process tests/long_book_example/src/01_getting_started/02_article.md twice in the same book. But loading markdown and processing structure takes place in mdbook_driver. Something there must add the chapter twice.

@blandger
Copy link
Collaborator

blandger commented Dec 1, 2025

twice in the same book.

Yes, resources get into epub archive twice and the check is failed. I will pull your branch and see details.

@blandger blandger mentioned this pull request Dec 4, 2025

let mut added_count = 0;
for (idx, item) in self.ctx.book.sections.iter().enumerate() {
for (idx, item) in self.ctx.book.iter().enumerate() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.ctx.book.iter() - now returns Items + SubItems as one long list.
So that code is ok.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But code at the end of method
fn add_chapter(&mut self, ch: &Chapter, is_first: Option<bool>) -> Result<(), Error>

that block

// second pass to actually add the sub-chapters
        for sub_item in &ch.sub_items {
            if let BookItem::Chapter(ref sub_ch) = *sub_item {
                trace!("add sub-item = {:?}", sub_ch.name);
                self.add_chapter(sub_ch, None)?;
            }
        }

Should be removed because it causes duplicate Chapter is added to book.

Copy link
Collaborator

@blandger blandger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove not needed code that causes test error.


let mut added_count = 0;
for (idx, item) in self.ctx.book.sections.iter().enumerate() {
for (idx, item) in self.ctx.book.iter().enumerate() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But code at the end of method
fn add_chapter(&mut self, ch: &Chapter, is_first: Option<bool>) -> Result<(), Error>

that block

// second pass to actually add the sub-chapters
        for sub_item in &ch.sub_items {
            if let BookItem::Chapter(ref sub_ch) = *sub_item {
                trace!("add sub-item = {:?}", sub_ch.name);
                self.add_chapter(sub_ch, None)?;
            }
        }

Should be removed because it causes duplicate Chapter is added to book.

@blandger
Copy link
Collaborator

blandger commented Dec 7, 2025

Then tests:

    test_footnote_definition_has_backreference_link
    test_footnote_definition_label
    test_footnote_has_linked_label

will need investigation and fixes too.

@blandger
Copy link
Collaborator

blandger commented Dec 7, 2025

will need investigation and fixes too.

Looks like all is ok with them.

@blandger blandger merged commit 7e1cf80 into Michael-F-Bryan:master Dec 9, 2025
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance doesn't follow mainstream mdbook?

2 participants